package com.lcb.demo;

import org.junit.Test;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.*;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.ResourceLoader;
import org.springframework.util.ReflectionUtils;

/****
 * @Author:刘长柏
 * @Date: 2021-03-02 14:21
 * @Description:入口测试类
 *****/
@SuppressWarnings("deprecation")
public class BeanFactoryTest {

    @Test
    public void testSimpleLoad() {
        BeanFactory beanFactory = new XmlBeanFactory(new ClassPathResource("beans.xml"));
        MyTestBean myTestBean = (MyTestBean) beanFactory.getBean("myTestBean");
        System.out.println(myTestBean.getTestStr());


        /**
         * 1.核心类DefaultListableBeanFactory 和 XmlBeanDefinitionReader
         *
         *ResourceLoader
         *
         *
         */
    }

    @Test
    public void testSimpleLoad1() {


        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("beans.xml");
        MyTestBean myTestBean = (MyTestBean) context.getBean("myTestBean");
        System.out.println(myTestBean.getTestStr());


        /**
         * 1.核心类DefaultListableBeanFactory 和 XmlBeanDefinitionReader
         *
         *ResourceLoader
         *
         *
         */
    }


}
